# coding:utf-8
"""
description:driver配置，测试机和模拟机配置
"""
from appium import webdriver
from common.Log import LOG


class driver_configure:

    def get_driver(self):
        """获取driver"""
        try:
            self.desired_caps = {}
            self.desired_caps['platformName'] = 'Android'  # 平台
            # self.desired_caps['platformVersion'] = '8.0'  # 系统版本
            self.desired_caps['appPackage'] = 'com.aztech.aztechkylas'  # APK包名
            self.desired_caps['appActivity'] = 'com.aztech.aztechkylas.SplashScreenActivity'  # 被测程序启动时的Activity
            self.desired_caps['unicodeKeyboard'] = True  # 是否支持unicode的键盘。如果需要输入中文，要设置为“true”
            self.desired_caps['resetKeyboard'] = True  # 是否在测试结束后将键盘重置为系统默认的输入法。
            self.desired_caps['newCommandTimeout'] = '120'  # Appium服务器待appium客户端发送新消息的时间。默认为60秒
            self.desired_caps['deviceName'] = '127.0.0.1:62001'  # 夜神模拟器
            # self.desired_caps['deviceName'] = 'LG_H990' # 手机,LG_H990
            self.desired_caps['noReset'] = True  # True:不重新安装APP，False:重新安装app
            self.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", self.desired_caps)
            return self.driver
        except Exception as e:
            LOG.error("链接测试机失败:%s" % e)
            raise e
